package cn.wubo.xianxiacomment

import com.intellij.openapi.application.ApplicationManager
import com.intellij.openapi.components.PersistentStateComponent
import com.intellij.openapi.components.State
import com.intellij.openapi.components.Storage
import com.intellij.util.xmlb.XmlSerializerUtil

@State(name = "OllamaConfigService", storages = [Storage("xianxia-comment.xml")])
class OllamaConfigService : PersistentStateComponent<OllamaConfigService?> {
    var ollamaUrl: String = "http://localhost:11434"
    var modelName: String = "gemma3"

    override fun getState(): OllamaConfigService? {
        return this
    }

    override fun loadState(state: OllamaConfigService) {
        XmlSerializerUtil.copyBean(state, this)
    }

    companion object {
        val instance: OllamaConfigService
            get() = ApplicationManager.getApplication().getService(OllamaConfigService::class.java)
    }
}